package edu.bw.controller.restful;

import edu.bw.vo.User;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    /**
     * GET /user/3
     */
    @GetMapping("/{id}")
    public User findById(@PathVariable("id") Integer uid){
        System.out.println(uid);
        return new User(uid,"张三","123456");// 根据uid查询用户信息
    }


    @PostMapping
    public User saveUser(@RequestBody User user){
        System.out.println("保存的用户信息:"+user);//模拟保存用户信息
        return user;
    }

    @PutMapping
    public User updateUser(@RequestBody User user){
        System.out.println("更新用户信息:"+user);
        return user;
    }

    /**
     *               `DELETE /user/3`
     * @return
     */
    @DeleteMapping("/{id}")
    public Integer deleteUser(@PathVariable("id") Integer uid){
        System.out.println("删除的用户的id:"+uid);
        return uid;
    }


}
